package cn.byapps.hw.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

@Entity
@Table(name = "Student")
@Data
@EqualsAndHashCode(of = {"id"})
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler"})
@AllArgsConstructor
@NoArgsConstructor
public class Student implements Serializable {
    @Id
    @Column(name = "id", length = 20)
    private String id;
    @Column(name = "name", length = 30)
    private String name;
    @Column(name = "password", length = 50)
    private String password;
    @Column(name = "phone", length = 30)
    private String phone;
    @ManyToMany
    @JoinTable(name = "_student_clazz", joinColumns = {@JoinColumn(name = "std_id")}, inverseJoinColumns = {
            @JoinColumn(name = "cls_id")})
    private Set<Clazz> clazzs = new HashSet<Clazz>();

}
